<template>
  <div :class="data?.isWarn ? 'cu-capsule warnShadow2' : 'cu-capsule'">
    <div class="cu-tag bg-blue text-lg">{{ title }}</div>
    <div class="cu-tag line-blue text-lg tag-value">
      <slot>{{ _value }}</slot>
    </div>
    <div class="warn-tag">!!!</div>
  </div>
</template>

<script>
export default {
  name: "HdItem",
  props: {
    value: "",
    title: {
      type: String,
      default: "",
    },
    data: {
      type: Object,
    },
    options: {
      type: Array,
      default: null,
    },
  },
  computed: {
    _value() {
      if (this.value) {
        if (this.options) {
          let tmp = this.options.filter((o) => o.key == this.value);
          if (tmp[0]) return tmp[0].value;
        }
        return this.value + (this.data?.unit || "");
      } else {
        return "&nbsp;";
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.warnShadow2 {
  border-radius: 2px;
  animation: warnShadow2 1s infinite alternate;
  .tag-value {
    color: #c11616;
  }
  .warn-tag {
    display: inline;
    float: right;
    font-size: 20px;
    padding-right: 10px;
    color: red;
  }
}

@keyframes warnShadow2 {
  from {
    box-shadow: 0px 0px 2px 1px #c11616 inset;
  }

  to {
    box-shadow: 0px 0px 10px 2px #c11616 inset;
  }
}
.warn-tag {
  display: none;
}
.bg-blue {
  background-color: #0d6a8b;
  color: #ffffff;
}
.text-blue,
.line-blue,
.lines-blue {
  color: #29e97f;
}
.cu-capsule {
  //display: inline-flex;
  vertical-align: middle;
  margin-right: 4px;
}
.cu-capsule .cu-tag {
  margin: 0;
}
.cu-tag {
  font-size: 20px;
  vertical-align: middle;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 3px 5px;
  height: 30px;
  font-family: Helvetica Neue, Helvetica, sans-serif;
  white-space: nowrap;
}
.cu-capsule .cu-tag[class*="line-"]:last-child::after {
  border-left: 0px solid transparent;
}

.cu-tag[class*="line-"]::after {
  border-radius: 0;
}

.cu-tag[class*="line-"]::after {
  content: " ";
  width: 200%;
  height: 200%;
  position: absolute;
  top: 0;
  left: 0;
  border: 1px solid currentColor;
  -webkit-transform: scale(0.5);
  transform: scale(0.5);
  -webkit-transform-origin: 0 0;
  transform-origin: 0 0;
  box-sizing: border-box;
  border-radius: inherit;
  z-index: 1;
  pointer-events: none;
}

.line-blue::after,
.lines-blue::after {
  border-color: #29e97f;
}
</style>
